package com.letv.android.client.episode.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.letv.android.young.client.R;
import com.letv.android.client.adapter.LetvBaseAdapter;
import com.letv.android.client.episode.fragment.HalfPlayVideosFragment;
import com.letv.android.client.episode.utils.EpisodeUtils;
import com.letv.android.client.utils.UIs;
import com.letv.android.client.widget.LetvImageView;
import com.letv.core.bean.AlbumNew;
import com.letv.core.bean.CmsBean;
import com.letv.core.bean.LetvBaseBean;
import com.letv.core.bean.RecommendBean;
import com.letv.core.bean.VideoBean;
import com.letv.core.download.image.ImageDownloader;
import com.letv.core.utils.LogInfo;
import com.letv.core.utils.UIsUtils;

import java.util.HashMap;
//import com.letv.download.bean.DownloadVideo;
//import com.letv.download.manager.DownloadManager;


public class NewDetailHalfVideosListAdapter extends LetvBaseAdapter {
	
	private long curId;

	private long aid;

	private boolean isDownload;
    /**
     * 锁
     * */
    private boolean lock;

    /**
     * 全屏or竖屏
     */
    private boolean isLandscape = false;

	/**
	 * 已添加到下载中的视频
	 */
	private HashMap<Long, Integer> downloadVideos = new HashMap<Long, Integer>();
	
	private Context mContext;
	
	/**
	 * 显示集数（<60集才显示）
	 */
	private RelativeLayout detailplayHalfVideoLayout;
	private TextView videosNumTView;
	private TextView jumpDescView;
	private TextView jumpArrowView;
	
	/*
	 * 周边视频标题显示
	 */
	private LinearLayout detailplaySurroundLayout;
	private TextView surroundTitle;

    private int same,special,count;
	
	public NewDetailHalfVideosListAdapter(Context context) {
        super(context);
        mContext = context;
    }
    /**
     * 清空上次使用时的图片资源和监听资源
     * */
    public void clearViewData(PortraitViewHolder mViewHolder) {
        if (mViewHolder.videoImageView != null) {
            mViewHolder.videoImageView.setImageDrawable(null);
        }
        mViewHolder.localTextView.setText("");
        mViewHolder.titleView.setText("");
        mViewHolder.subTitleView.setText("");
        mViewHolder.playNumView.setText("");
        mViewHolder.videoTime.setText("");
    }

    public void setIsLandscape(boolean isLandscape) {
        this.isLandscape = isLandscape;
    }

    @Override
	public int getItemViewType(int position) {
        LetvBaseBean letvBaseBean = (LetvBaseBean) getItem(position);
        if (letvBaseBean instanceof VideoBean) {
            return ((VideoBean) letvBaseBean).getItemType() == 0 ? HalfPlayVideosFragment.VIDEO_EPISODE_ITEM : ((VideoBean) getItem(position)).getItemType();
        }
        return HalfPlayVideosFragment.VIDEO_EPISODE_ITEM;
	}
    
    @Override
    public int getViewTypeCount() {
		return HalfPlayVideosFragment.VIDEO_EPISODE_ITEM_TOTAL;
	}    
    
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
        if (isLandscape) {
            convertView = configurationLandscapeConvertView(position, convertView, parent);
        } else {
            convertView = configurationPortraitConvertView(position, convertView, parent);
        }
		return convertView;
	}

    private void showRecommendItem(LandscapeViewHolder landscapeViewHolder, RecommendBean recommendBean) {
        if (recommendBean.cid == AlbumNew.Channel.TYPE_TVSHOW) {
            landscapeViewHolder.text.setText(recommendBean.title);
        } else if (recommendBean.cid == AlbumNew.Channel.TYPE_MUSIC) {// 播放页列表需要加入歌手字段（即，歌名+歌手）
            landscapeViewHolder.text.setText(recommendBean.title);
            if (!TextUtils.isEmpty(recommendBean.starring)) {
                landscapeViewHolder.subTitle.setText(recommendBean.starring);
                landscapeViewHolder.subTitle.setVisibility(View.VISIBLE);
            }
        } else {
            if (recommendBean.type == 1 ){
                landscapeViewHolder.text.setText(recommendBean.pidname);
            }else if(recommendBean.type == 3){
                landscapeViewHolder.text.setText(recommendBean.title);
            }
        }
    }

    private void showVideoItem(LandscapeViewHolder landscapeViewHolder, VideoBean videoBean) {
        if (videoBean.getCid() == AlbumNew.Channel.TYPE_TVSHOW) {
            landscapeViewHolder.text.setText(videoBean.getNameCn());
        } else if (videoBean.getCid() == AlbumNew.Channel.TYPE_MUSIC) {
            // 播放页列表需要加入歌手字段（即，歌名+歌手）
            landscapeViewHolder.text.setText(videoBean.getNameCn());
            if (!TextUtils.isEmpty(videoBean.getSinger())) {
                landscapeViewHolder.subTitle.setText(videoBean.getSinger());
                landscapeViewHolder.subTitle.setVisibility(View.VISIBLE);
            }
        } else {
            if (!TextUtils.isEmpty(videoBean.getNameCn())) {
                landscapeViewHolder.text.setText(videoBean.getNameCn());
            } else if (!TextUtils.isEmpty(videoBean.getTitle())) {
                landscapeViewHolder.text.setText(videoBean.getTitle());
            }
        }
    }

    private void showCmsItem(LandscapeViewHolder landscapeViewHolder, CmsBean cmsBean) {
        if (cmsBean.getCid() == AlbumNew.Channel.TYPE_TVSHOW) {
            landscapeViewHolder.text.setText(cmsBean.getNameCn());
        } else if (cmsBean.getCid() == AlbumNew.Channel.TYPE_MUSIC) {
            landscapeViewHolder.text.setText(cmsBean.getNameCn());
            if (!TextUtils.isEmpty(cmsBean.getSinger())) {
                landscapeViewHolder.subTitle.setText(cmsBean.getSinger());
                landscapeViewHolder.subTitle.setVisibility(View.VISIBLE);
            }
        } else {
            landscapeViewHolder.text.setText(cmsBean.getNameCn());
        }
    }

//    private void recordVideoStatus(boolean isDownLoad,DownloadVideo dbBean,LandscapeViewHolder mLandscapeViewHolder){
//        if (dbBean !=null) {
//            if (dbBean.state == 4) {// 完成
//                mLandscapeViewHolder.check.setVisibility(View.GONE);
//                mLandscapeViewHolder.localTip.setVisibility(View.VISIBLE);
//            }else{
//                if(isDownLoad){
//                    mLandscapeViewHolder.check.setVisibility(View.VISIBLE);
//                }else{
//                    mLandscapeViewHolder.check.setVisibility(View.GONE);
//                }
//                mLandscapeViewHolder.localTip.setVisibility(View.GONE);
//            }
//        }else{
//            mLandscapeViewHolder.localTip.setVisibility(View.GONE);
//            mLandscapeViewHolder.check.setVisibility(View.GONE);
//        }
//    }

    /**
     * 配置竖屏的convertView
     * @param position
     * @param convertView
     * @param parent
     * @return
     */
    private View configurationPortraitConvertView(int position, View convertView, ViewGroup parent) {
        VideoBean videoBean = (VideoBean) getItem(position);
        PortraitViewHolder mViewHolder = null;
        LogInfo.log("hong", "NewDetailHalfVideosListAdapter getView " + position);
        int type = getItemViewType(position);
        if (convertView == null) {
	        switch (type) {
		        case HalfPlayVideosFragment.VIDEO_EPISODE_ITEM:
		        case HalfPlayVideosFragment.VIDEO_EPISODE_SURROUND_ITEM:
		        	convertView = UIsUtils.inflate(mContext, R.layout.letv_detailplay_half_list_item_playerlibs, parent, false);
		    		mViewHolder = new PortraitViewHolder();
		            mViewHolder.localTextView = (TextView)convertView.findViewById(R.id.videos_list_item_download_state_txt);
		            mViewHolder.titleView = (TextView)convertView.findViewById(R.id.videos_list_item_title);
		            mViewHolder.subTitleView = (TextView)convertView.findViewById(R.id.videos_list_item_subtitle);
		            mViewHolder.playNumView = (TextView)convertView.findViewById(R.id.videos_list_item_playnum);
		            mViewHolder.videoTime = (TextView)convertView.findViewById(R.id.video_time);
		            mViewHolder.videoImageView = (LetvImageView)convertView.findViewById(R.id.detail_half_video_image);
		            mViewHolder.recommendView = convertView.findViewById(R.id.tuijian_view);
		            convertView.setTag(mViewHolder);
					break;
				case HalfPlayVideosFragment.VIDEO_EPISODE_SURROUND_TITLE:
					convertView = UIsUtils.inflate(mContext, R.layout.letv_detailplay_half_videos_surround_title, parent, false);
					detailplaySurroundLayout = (LinearLayout) convertView.findViewById(R.id.detail_half_videos_count_layout);
					surroundTitle = (TextView) convertView.findViewById(R.id.detail_half_videos_surround_title);
					surroundTitle.setText(videoBean == null ? "":videoBean.getTitle());
		        	break;
		    	default:
		    		break;
	        }
        }
        else {
        	switch (type) {
            case HalfPlayVideosFragment.VIDEO_EPISODE_ITEM:
            case HalfPlayVideosFragment.VIDEO_EPISODE_SURROUND_ITEM:
            	mViewHolder = (PortraitViewHolder) convertView.getTag();
                clearViewData(mViewHolder);
    			break;
        	default:
        		break;
        	}
        }
        switch (type) {
	        case HalfPlayVideosFragment.VIDEO_EPISODE_ITEM:
	        case HalfPlayVideosFragment.VIDEO_EPISODE_SURROUND_ITEM:
	        	createVideosList(curId, mViewHolder, videoBean, convertView);
				break;
	    	default:
	    		break;
    	}
        return convertView;
    }

    /**
     * 全屏
     * @param position
     * @param convertView
     * @param parent
     * @return
     */
    private View configurationLandscapeConvertView(int position, View convertView, ViewGroup parent) {
        LetvBaseBean letvBaseBean = (LetvBaseBean) getItem(position);
        LandscapeViewHolder landscapeViewHolder = null;
        if (convertView == null) {
            landscapeViewHolder = new LandscapeViewHolder();
            convertView = UIsUtils.inflate(mContext, R.layout.letv_player_listview_item_playerlibs, parent, false);
            landscapeViewHolder.childListItemRootLayout=(FrameLayout)convertView.findViewById(R.id.childListItemRootLayout);
            landscapeViewHolder.text = (TextView) convertView.findViewById(R.id.player_movie_item_txt);
            landscapeViewHolder.subTitle = (TextView) convertView.findViewById(R.id.videos_list_item_subTitle);
            landscapeViewHolder.player_movie_item_layout = (RelativeLayout) convertView.findViewById(R.id.player_movie_item_layout);
            landscapeViewHolder.check = convertView.findViewById(R.id.player_movie_item_check);
            landscapeViewHolder.localTip=(TextView)convertView.findViewById(R.id.local_tip);
            convertView.setTag(landscapeViewHolder);
        } else {
            landscapeViewHolder = (LandscapeViewHolder) convertView.getTag();
        }
        ViewGroup.LayoutParams childListItemLy= landscapeViewHolder.player_movie_item_layout.getLayoutParams();
        landscapeViewHolder.player_movie_item_layout.setLayoutParams(childListItemLy);
        same = UIs.zoomWidth(mContext, 10);
        special = UIs.zoomWidth(mContext,5);
        if(position == 0){
            landscapeViewHolder.childListItemRootLayout.setPadding(same, 0, same, special / 2);
        }else if(position == getCount() - 1){
            landscapeViewHolder.childListItemRootLayout.setPadding(same, special / 2, same, special);
        }else{
            landscapeViewHolder.childListItemRootLayout.setPadding(same, special / 2, same, special / 2);
        }
        landscapeViewHolder.subTitle.setVisibility(View.GONE);
        long id = 0;
        if (letvBaseBean instanceof VideoBean) {
            VideoBean videoBean = (VideoBean) letvBaseBean;
            id = videoBean.getId();
            showVideoItem(landscapeViewHolder, videoBean);
        } else if (letvBaseBean instanceof RecommendBean) {
            RecommendBean recommendBean = (RecommendBean) letvBaseBean;
            if (null != recommendBean) {
                id = recommendBean.id;
                showRecommendItem(landscapeViewHolder, recommendBean);
            }
        }
//        DownloadVideo dbBean = null;
//        if (letvBaseBean != null) {
//            dbBean = DownloadManager.getDownloadedVideoData(String.valueOf(id));
//        }
//        recordVideoStatus(isDownload, dbBean, landscapeViewHolder);
        if (isDownload) {
            landscapeViewHolder.player_movie_item_layout.setSelected(false);
        } else {
            if (curId == id) {
                landscapeViewHolder.player_movie_item_layout.setSelected(true);
                landscapeViewHolder.localTip.setTextColor(Color.WHITE);
            } else {
                landscapeViewHolder.player_movie_item_layout.setSelected(false);
                landscapeViewHolder.localTip.setTextColor(Color.parseColor("#67b716"));
            }
        }
        return convertView;
    }

    /**
     * 创建列表
     */
    private void createVideosList(long curId, PortraitViewHolder mViewHolder, VideoBean mVideo, View convertView){
    	if(mVideo == null) {
    		return;
    	}
    	//cms推荐数据
        if(mVideo.isHaveSurrVideo()){
            mViewHolder.recommendView.setVisibility(View.VISIBLE);            
            if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                mViewHolder.titleView.setVisibility(View.VISIBLE);
            	mViewHolder.titleView.setText(mVideo.getNameCn());
                mViewHolder.titleView.setMaxLines(2);
			}
            else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                mViewHolder.titleView.setVisibility(View.VISIBLE);
                mViewHolder.titleView.setText(mVideo.getTitle());
                mViewHolder.titleView.setMaxLines(2);
            }
            else{
				mViewHolder.titleView.setVisibility(View.GONE);
			}
            if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                mViewHolder.subTitleView.setSingleLine();
                mViewHolder.titleView.setSingleLine();
            	mViewHolder.subTitleView.setText(mVideo.getSubTitle());
            	mViewHolder.subTitleView.setVisibility(View.VISIBLE);
			}else{
				mViewHolder.subTitleView.setVisibility(View.GONE);
			}            
            if (mVideo.getDuration() != 0 && (mVideo.getAt() == 1 || mVideo.getAt() == 2)) {
                mViewHolder.videoTime.setVisibility(View.VISIBLE);
                mViewHolder.videoTime.setText(EpisodeUtils.stringForTimeNoHour(mVideo.getDuration() * 1000));
            }
            else if (!TextUtils.isEmpty(mVideo.getCornerMark())) {
                mViewHolder.videoTime.setVisibility(View.VISIBLE);
                mViewHolder.videoTime.setText(mVideo.getCornerMark());
            }
            else {
                mViewHolder.videoTime.setVisibility(View.GONE);
            }
            mViewHolder.playNumView.setVisibility(View.GONE);
            mViewHolder.videoImageView.setTag(null);
            if (!TextUtils.isEmpty(getImageUrl(mVideo.getPic300(), mVideo.getPic320()))) {
                ImageDownloader.getInstance(mContext).download(mViewHolder.videoImageView, getImageUrl(mVideo.getPic300(), mVideo.getPic320()));
            }
            else {
                ImageDownloader.getInstance(mContext).download(mViewHolder.videoImageView, mVideo.getPic320_200());
            }
        } else {
        	//周边视频
            mViewHolder.recommendView.setVisibility(View.GONE);
            //Modify for 5.7 requirement by zhanghongfei ,hide subTitleView
            mViewHolder.subTitleView.setText("");
            mViewHolder.subTitleView.setVisibility(View.GONE);
            int cid = Integer.valueOf(mVideo.getCid()); 
            switch (cid) {
                case AlbumNew.Channel.TYPE_H265:
                case AlbumNew.Channel.TYPE_MOVIE:
                case AlbumNew.Channel.TYPE_DOLBY:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {                        
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    if (!TextUtils.isEmpty(mVideo.getSubTitle()) && mVideo.getVideoTypeKey().equals("180001")) {
                        mViewHolder.subTitleView.setVisibility(View.VISIBLE);
                        mViewHolder.subTitleView.setText(mVideo.getSubTitle());
                        mViewHolder.subTitleView.setSingleLine();
                        mViewHolder.titleView.setSingleLine();
                    } else {
                        mViewHolder.titleView.setMaxLines(2);
                    }
                    //缺少播放数
                    break;
                case AlbumNew.Channel.TYPE_TVSHOW:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);                    
                    if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                        mViewHolder.titleView.setText(mVideo.getSubTitle());
                    } else if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    mViewHolder.subTitleView.setVisibility(View.GONE);
                    mViewHolder.titleView.setMaxLines(2);
                    break;
                case AlbumNew.Channel.TYPE_MUSIC:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    if (!TextUtils.isEmpty(mVideo.getSinger())) {
                        mViewHolder.subTitleView.setVisibility(View.VISIBLE);
                        mViewHolder.subTitleView.setText(mContext.getResources().getString(R.string.play_half_video_musician_title) + mVideo.getSinger());
                        mViewHolder.subTitleView.setSingleLine();
                        mViewHolder.titleView.setSingleLine();
                    } else {
                        mViewHolder.subTitleView.setVisibility(View.GONE);
                        mViewHolder.titleView.setMaxLines(2);
                    }
                    break;
                case AlbumNew.Channel.TYPE_DOCUMENT_FILM:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    mViewHolder.titleView.setMaxLines(2);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                        mViewHolder.titleView.setText(mVideo.getSubTitle());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    break;
                //体育/热点/NBA/财经/汽车/旅游
                //缺少财经---------
                case AlbumNew.Channel.TYPE_PE:
                case AlbumNew.Channel.TYPE_NBA:
                case AlbumNew.Channel.TYPE_FINANCIAL:
                case AlbumNew.Channel.TYPE_CAR:
                case AlbumNew.Channel.TYPE_TOURISM:
                case AlbumNew.Channel.TYPE_FASHION:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    mViewHolder.titleView.setMaxLines(2);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    } 
                    else if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                        mViewHolder.titleView.setText(mVideo.getSubTitle());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    break;
                case AlbumNew.Channel.TYPE_JOY:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    mViewHolder.titleView.setMaxLines(2);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    } 
                    else if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                        mViewHolder.titleView.setText(mVideo.getSubTitle());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    break;
                default:
                    mViewHolder.titleView.setVisibility(View.VISIBLE);
                    mViewHolder.titleView.setMaxLines(2);
                    if (!TextUtils.isEmpty(mVideo.getNameCn())) {
                        mViewHolder.titleView.setText(mVideo.getNameCn());
                    } 
                    else if (!TextUtils.isEmpty(mVideo.getSubTitle())) {
                        mViewHolder.titleView.setText(mVideo.getSubTitle());
                    }
                    else if (!TextUtils.isEmpty(mVideo.getTitle())) {
                        mViewHolder.titleView.setText(mVideo.getTitle());
                    }
                    break;
            }
            if (mVideo.getDuration() != 0) {
                mViewHolder.videoTime.setVisibility(View.VISIBLE);
                mViewHolder.videoTime.setText(EpisodeUtils.stringForTimeNoHour(mVideo.getDuration() * 1000));
            }
            else if (!TextUtils.isEmpty(mVideo.getCornerMark())) {
                mViewHolder.videoTime.setVisibility(View.VISIBLE);
                mViewHolder.videoTime.setText(mVideo.getCornerMark());
            }
            else {
                mViewHolder.videoTime.setVisibility(View.GONE);
            }
            if (mVideo.getPlayCount() != 0) {
            	mViewHolder.playNumView.setVisibility(View.VISIBLE);
            	mViewHolder.playNumView.setText(EpisodeUtils.getPlayCountsToStr(Long.valueOf(mVideo.getPlayCount())));
            }
            else {
            	mViewHolder.playNumView.setVisibility(View.GONE);
            }
            
            if (!TextUtils.isEmpty(getImageUrl(mVideo.getPic300(), mVideo.getPic320()))) {
                ImageDownloader.getInstance(mContext).download(mViewHolder.videoImageView, getImageUrl(mVideo.getPic300(), mVideo.getPic320()));
            }
            else {
                ImageDownloader.getInstance(mContext).download(mViewHolder.videoImageView, mVideo.getPic320_200());
            }

            int dbBeanFinish = -1;
            if (mVideo.getDownload() == 1 && downloadVideos.size() > 0) {
                if (downloadVideos.containsKey(mVideo.getId())) {
                    dbBeanFinish = downloadVideos.get(mVideo.getId());
                }
            }
            if (dbBeanFinish >= 0) {
                if (dbBeanFinish == 4) {// 完成
                    mViewHolder.localTextView.setVisibility(View.VISIBLE);
                    mViewHolder.localTextView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ff67b716));
//                    mViewHolder.localTextView.setText(R.string.download_finish_local);
                } else {// 未完成
                    mViewHolder.localTextView.setVisibility(View.GONE);
                }
            } else {
            	mViewHolder.localTextView.setVisibility(View.INVISIBLE);
                convertView.setBackgroundResource(R.color.letv_color_00ffffff);
            }
            if (curId == mVideo.getId()) {
                mViewHolder.titleView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ffffffff));
                mViewHolder.subTitleView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ffffffff));
                mViewHolder.playNumView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ffffffff));
                mViewHolder.playNumView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.letv_playnum_select, 0, 0, 0);
                convertView.setBackgroundResource(R.color.letv_color_ff00a0e9);
            } else {
                mViewHolder.titleView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ff5c5c5c));
                mViewHolder.subTitleView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ff969696));
                mViewHolder.playNumView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.letv_playnum_normal, 0, 0, 0);
                mViewHolder.playNumView.setTextColor(mContext.getResources().getColor(R.color.letv_color_ff969696));
                convertView.setBackgroundResource(R.drawable.letv_half_play_relate_item_selecter);
//                convertView.setBackgroundResource(R.color.letv_color_ffffffff);
            }
            
        }
    }

    /**
     * block图片地址获取
     * @return String
     */
    private String getImageUrl(String imgUrlPic, String imgUrlPic300) {
        if (!TextUtils.isEmpty(imgUrlPic)) {
            return imgUrlPic;
        } else {
            return imgUrlPic300;
        }
    }

	public class PortraitViewHolder {
        public LetvImageView videoImageView;
        public View recommendView;
        public TextView titleView;
        public TextView subTitleView;
        public TextView playNumView;
        public TextView localTextView;
        public TextView videoTime;
    }

    public class LandscapeViewHolder {
        public RelativeLayout player_movie_item_layout;
        public TextView text; //主标题
        private TextView subTitle;//副标题
        public FrameLayout childListItemRootLayout;
        public View check;
        public TextView localTip;
    }

	public long getCurId() {
		return curId;
	}

	public void setCurId(long curId) {
		this.curId = curId;
	}

	public long getAid() {
		return aid;
	}

	public void setAid(long aid) {
		this.aid = aid;
//		if (aid > 0) {
//			DownloadTraceHandler downloadTraceHandler = new DownloadTraceHandler(mContext);
//			List<DownloadDBBean> infos = downloadTraceHandler.getAllDownloadInfoWithAid(aid);
//			downloadVideos.clear();
//			if(infos != null && infos.size() > 0){
//				for (DownloadDBBean downloadDBBeanPlayerLibs : infos) {
//					downloadVideos.put((long) downloadDBBeanPlayerLibs.getEpisodeid(), downloadDBBeanPlayerLibs.getFinish());
//				}
//			}
//		}
	}

	public boolean isDownload() {
		return isDownload;
	}

    public void lock() {
        lock = true;
    }

    public void unLock() {
        lock = false;
    }

	public void setDownload(boolean isDownload) {
		this.isDownload = isDownload;
	}
}
